/*
    Project:        Home Power Control
    File:           HPCLogDevice.h
    Author:         christian@karunamusic.at
    Date:           01.2015
    Description:    Baseclass for subscribers of logmessages.
 */

#ifndef HPCLOGDEVICE_H
#define HPCLOGDEVICE_H

#include <QObject>
#include <QString>
#include "HPCLogger.h"

class HPCLogDevice : public QObject
{
    Q_OBJECT
public:
    /** \brief Constructor
     * Set th loglevel of this target and connect to the logevent.
     *
     * \param lv The loglevel.
     */
    explicit HPCLogDevice( TLogLevel lv );
    /** \brief Constructor
     * Set th loglevel of this target and connect to the logevent.
     *
     * \param lv The loglevel.
     */
    explicit HPCLogDevice( const QString& lv );
    /** \brief Destructor
     * Disconnects from the logevent.
     */
    virtual ~HPCLogDevice();

    /**< Get the loglevel. */
    inline TLogLevel LogLevel() const
        { return m_LogLevel; }
    /**< Set the loglevel. */
    inline HPCLogDevice& LogLevel( TLogLevel lv )
        { m_LogLevel = lv; return *this; }

signals:

public slots:
    /** \brief Slot for the logmessage.
     * This method is registered to the logevent as a slot to recieve the logmessage.
     * This is an abstract method and has to be implemented in derived classes!
     *
     * \param lm the logmessage
     */
    virtual void OnLog( const HPCLogMessage& lm ) = 0;


private:
    TLogLevel m_LogLevel; /**< the loglevel */
};

#endif // HPCLOGDEVICE_H
